package Serveur;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.HashMap;

import controleur.ToutFenetre;

import view.Fenetre1;
import view.Fenetre3;

import Both.Billet;
import Both.Passager;
import Both.ProfilPassager;
import Both.Trajet;
import Both.Transport;
import Both.TypeBillet;
import Both.TypeTransport;
import Both.Ville;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        
        /*
        Transport trans = new Transport(TypeTransport.CAR, 5, 5);
        
        
        Trajet t = new Trajet(Ville.LYON, Ville.NICE,
                new GregorianCalendar(2011, Calendar.DECEMBER, 20, 17, 20), new GregorianCalendar(2011, Calendar.DECEMBER, 20, 17, 20) ,
                trans, 300);
        
        Reservation resa = new Reservation(t, 2);
        
        try {
            //Store
            XMLTools.store(t, "trajet", "1");
            
            //Load
            Trajet p = (Trajet)XMLTools.load("trajet", "1");
            
            System.out.println(p);
            
            
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println(e.getMessage());
        }
        
        */
        
         
        
        Serveur serveur = new Serveur();
        
        Transport trans = new Transport(TypeTransport.VOITURE, 5, 5);
        Transport bus = new Transport(TypeTransport.BUS, 1, 50);
        
        
        Trajet t0 = new Trajet(Ville.LYON, Ville.MARSEILLE,  new GregorianCalendar(2011, Calendar.DECEMBER, 20, 13, 20), 
                                new GregorianCalendar(2011, Calendar.DECEMBER, 20, 15, 40),trans, 500);
        
        Trajet t1 = new Trajet(Ville.MARSEILLE, Ville.NICE, new GregorianCalendar(2011, Calendar.DECEMBER, 20, 15, 50), 
                                new GregorianCalendar(2011, Calendar.DECEMBER, 20, 17, 10), bus, 200);
        
        Trajet t2 = new Trajet(Ville.LYON, Ville.PARIS, new GregorianCalendar(2011, Calendar.DECEMBER, 20, 13, 10), 
                                new GregorianCalendar(2011, Calendar.DECEMBER, 20, 16, 10), trans, 450);
        
        Trajet t3 = new Trajet(Ville.PARIS, Ville.LYON, new GregorianCalendar(2011, Calendar.DECEMBER, 20, 10, 10), 
                new GregorianCalendar(2011, Calendar.DECEMBER, 20, 11, 10), trans, 450);
        
        serveur.addTransport(trans);
        serveur.addTransport(bus);
        serveur.addTrajet(t0);
        serveur.addTrajet(t1);
        serveur.addTrajet(t2);
        serveur.addTrajet(t3);
        
        System.out.println(serveur.getListeTrajet().size());
        
        
        RechercheTransport r = new RechercheTransport(Ville.LYON, Ville.NICE, serveur.getListeTrajet());
        
        System.out.println(r.Chemin().size());
        System.out.println(r.Chemin().size());
        
        ArrayList<Trajet> tr = new ArrayList<Trajet>();
        tr.add(t0);
        tr.add(t1);
        
        System.out.println(tr);
        
        Billet b = new Billet(r.Chemin(), ProfilPassager.MILITAIRE, TypeBillet.NON_REMBOURSABLE, new HashMap<String, Double>(),1);
        
        b.genererRecapHTML();
        
        Passager nol = new Passager("Potier", "Nolan", "Nols", "pots", new GregorianCalendar(2011, Calendar.DECEMBER, 20, 10, 10), ProfilPassager.ADULTE);
        
        nol.ajouterBillet(b);
        serveur.addPassager(nol);
                
        serveur.closeServeur();
        
       
        
    }
        
    

}
